/**
 * @author Bernhard Denner
 * @author Maximilian Csuk
 * @author Konrad Paumann
 */
public class ISTree extends Tree<Integer, String> {

	public ISTree(Integer nodeTitle) {
		super(nodeTitle);
	}
	/**
	 * Returns the sum of all node titles where
	 * edges, which's titles are equal to name, point to 
	 */
	public int sum(String name) {
		int sum = 0;
		TreeNodeIterator<Integer, String> nit = getNodeIterator();
		TreeEdgeIterator<Integer, String> eit = getEdgeIterator();
		while(nit.hasNext()) {
			Tree<Integer, String> node = nit.next();
			String edge = eit.next();
			if (edge.equals(name))
				sum += node.getNodeTitle();
		}
		return sum;
	}
}
